package com.example.littleSpider.myapplication.activity;


import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.example.littleSpider.myapplication.R;
import com.example.littleSpider.myapplication.base.BaseActivity;
import com.example.littleSpider.myapplication.fragment.gankuai.recivesure.AcceptConfirmFragment;
import com.example.littleSpider.myapplication.fragment.gankuai.recivesure.SendConfirmFragment;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;


/**
 * Created by EDZ on 2017/12/14.
 *
 * 赶快 个人中心 网点收发货确认界面
 */

public class ReceivesureActivity extends BaseActivity{

    @BindView(R.id.tab_recivesure)
    TabLayout tab_recivesure;
    @BindView(R.id.vp_recivesure)
    ViewPager vp_recivesure;


    FragmentManager manager;
    List<Fragment> fragmentList = new ArrayList<>();

    AcceptConfirmFragment acceptConfirmFragment = new AcceptConfirmFragment();
    SendConfirmFragment sendConfirmFragment = new SendConfirmFragment();


    @Override
    protected int getLayoutRes() {
        return R.layout.activity_recivesure;
    }

    @Override
    protected void initView() {
        manager = getSupportFragmentManager();

        fragmentList.add(sendConfirmFragment);
        fragmentList.add(acceptConfirmFragment);


        tab_recivesure.setupWithViewPager(vp_recivesure);
        vp_recivesure.setAdapter(new MyPageAdapter(manager));

    }

    @OnClick({R.id.ll_back,R.id.tv_search})
    public void click(View view){
        switch (view.getId()){
            case R.id.ll_back:
                finish();
                break;
            case R.id.tv_search:
                break;
        }
    }



    @Override
    protected void initData() {

    }


    private class MyPageAdapter extends FragmentPagerAdapter {

        FragmentManager manager;

        public MyPageAdapter(FragmentManager fm) {
            super(fm);
            manager = fm;
        }

        @Override
        public Fragment getItem(int position) {
            return fragmentList.get(position);
        }

        @Override
        public int getCount() {
            return fragmentList.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            if (position == 0){
                return "发单确认";
            }else {
                return "到货确认";
            }
        }
    }
}

